package cn.kgc.ssm.controller;

import cn.kgc.ssm.commons.ResponseResult;
import cn.kgc.ssm.entity.Member;
import cn.kgc.ssm.service.MemberService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 课工场
 * @date 2024/5/16
 * @description   会员管理
 */
@RestController
@RequestMapping("member")
public class MemberController {

    @Resource
    private MemberService memberService;

    // 分页数据
    @RequestMapping("page")
    public ResponseResult memberPage(Integer page,Integer limit,String memberName){
       return memberService.memberPage(page,limit,memberName);
    }

    //添加会员
    @RequestMapping("add")
    public ResponseResult addMember(Member member){
        return memberService.addMember(member);
    }

    // 根据id获取会员信息
    @RequestMapping("getById")
    public ResponseResult getMember(Integer id){
        return memberService.getMember(id);
    }

    // 编辑会员信息
    @RequestMapping("edit")
    public ResponseResult editMember(Member member){
        return memberService.editMember(member);
    }

    // 删除会员信息
    @RequestMapping("delete")
    public ResponseResult deleteMember(Integer[] ids){
        return memberService.removeMember(ids);
    }

    // 重置密码
    @RequestMapping("reset")
    public ResponseResult resetPassword(Integer id){
        return memberService.resetPassword(id);
    }


    // 注册会员信息
    @RequestMapping("/front/register")
    public ResponseResult registerMember(Member member){
        return memberService.registerMember(member);
    }

    // 会员登录
    @RequestMapping("/front/login")
    public ResponseResult login(Member member, HttpServletRequest  request){
        return memberService.login(member,request);
    }




}
